// createRouter: 创建一个路由实例对象
// createWebHistory: 创建一个history路由模式
// createWebHashHistory: 创建一个hash路由模式
import { createRouter, createWebHashHistory } from 'vue-router'

import Login from '@/views/Login/index.vue'
import Layout from '@/views/Layout/index.vue'
import Home from '@/views/Home/index.vue'
import Category from '@/views/Category/index.vue'
import SubCategory from '@/views/SubCategory/index.vue'


// 创建路由实例
const router = createRouter({
  // 配置路由模式
  history: createWebHashHistory(import.meta.env.BASE_URL),
  // 路由规则数组
  routes: [
    { path: '/login', component: Login },
    {
      path: '/',
      component: Layout,
      children: [
        { path: '', component: Home },
        // 设置路由为动态路由
        { path: 'category/:id', component: Category },
        { path: 'category/sub/:id', component: SubCategory }
      ]
    }
  ]
})

// 导出路由实例对象
export default router
